var app = getApp()
Page({
  data: {
    user_id: '',
    class_num: [],
    coach_id:'',
    order_id:'',
    visible1: false
  },

  onLoad: function () {
    this.setData({
      user_id: wx.getStorageSync('uid')
    })
    this.classNum(this.data.user_id)
  },
  classNum(uid) {
    let that = this
    wx.request({
      url: app.url + 'weiapp/api/getMyClass',
      data: {
        uid: uid
      },
      success: function (res) {
        console.log(res.data.data)
        that.setData({
          class_num: res.data.data
        })
      }
    })
  },
  handleOpen(e) {
    console.log(e)
    wx.setStorageSync('select_order', e.currentTarget.dataset.order_id)
    this.setData({
      visible1: true
    });
  },
  handleClose() {
    this.setData({
      visible1: false
    });
  },
  startCourse() {
    this.setData({
      visible1: false
    })
    this.update()
  },
  update: function () {
    wx.request({
      url: app.url + '/weiapp/api/UpdateOrderClassNum',
      data: {
        order_id: wx.getStorageSync('select_order'),
        PHPSESSID: wx.getStorageSync('PHPSESSID')
      },
      success: function (res) {
        console.log(res)
        if (res.data.code == '100032') {
          wx.showToast({
            title: res.data.msg,
          })
        }
        if (res.data.code == '200') {
          wx.showToast({
            title: '上课成功',
          }),
            setTimeout(function () {
              wx.navigateTo({
                url: '../my_class/my_class',
              })

            }, 2000)

        }
      }
    })
  }


});